using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
using Joy.Erp.BasicArchives.Core.Filters;

namespace Joy.Erp.BasicArchives.Staff
{
    [RemoteService(Name = BasicArchivesRemoteServiceConsts.RemoteServiceName)]
    [Area(BasicArchivesRemoteServiceConsts.ModuleName)]
    [ControllerName("Department")]
    [Route("api/basic-archives/department")]
    public partial class DepartmentController : BasicArchivesController, IDepartmentAppService
    {
        protected IDepartmentAppService DepartmentAppService => LazyServiceProvider.LazyGetRequiredService<IDepartmentAppService>();

        [HttpGet]
        [Route("{id}")]
        public Task<DepartmentDto> GetAsync(Guid id)
        {
            return DepartmentAppService.GetAsync(id);
        }

        [HttpGet]
        [Route("find")]
        public Task<DepartmentDto> FindAsync(string filter)
        {
            return DepartmentAppService.FindAsync(filter);
        }

        [HttpGet]
        [Route("find-by-source-key")]
        public Task<DepartmentDto> FindBySourceKeyAsync(string sourceKey, string sourceType)
        {
            return DepartmentAppService.FindBySourceKeyAsync(sourceKey, sourceType);
        }

        [HttpGet]
        public Task<PagedResultDto<DepartmentDto>> GetListAsync(FilterRequestDto input)
        {
            return DepartmentAppService.GetListAsync(input);
        }

        [HttpPost]
        [Route("query")]
        public Task<PagedResultDto<DepartmentDto>> QueryAsync(FilterGroupRequestDto input)
        {
            return DepartmentAppService.QueryAsync(input);
        }

        [HttpPost]
        [Route("get-children")]
        public Task<ListResultDto<DepartmentDto>> GetChildrenAsync(Guid? parentId, bool recursive = false)
        {
            return DepartmentAppService.GetChildrenAsync(parentId, recursive);
        }

        [HttpPost]
        public Task<DepartmentDto> CreateAsync(DepartmentCreateDto input)
        {
            return DepartmentAppService.CreateAsync(input);
        }

        [HttpPut]
        [Route("{id}")]
        public Task<DepartmentDto> UpdateAsync(Guid id, DepartmentUpdateDto input)
        {
            return DepartmentAppService.UpdateAsync(id, input);
        }

        [HttpDelete]
        [Route("{id}")]
        public Task DeleteAsync(Guid id)
        {
            return DepartmentAppService.DeleteAsync(id);
        }
    }
} 